package slices

func Each[S ~[]T, T any](s S, f func(index int, element T) (continued bool)) {
	if len(s) == 0 {
		return
	}
	if f == nil {
		return
	}
	for i, e := range s {
		if !f(i, e) {
			break
		}
	}
}

func EachPtr[S ~[]*T, T any](s S, f func(index int, element *T) (continued bool)) {
	if len(s) == 0 {
		return
	}
	if f == nil {
		return
	}
	for i, e := range s {
		if !f(i, e) {
			break
		}
	}
}
